#########################################################################
# File Name: once.sh
# Brief:一键完成后台查询
# Author: lion
# mail: aolei1024@gmail.com
# Created Time: 2015年06月01日 星期一 22时10分44秒
#########################################################################
#!/bin/bash
echo $1
date1=`date -d $1 +%s`
beg=`date -d $1 +%s`
end=`date +%Y-%m-%d --date="-1 day ago $1"`
endTime=`date -d $end +%s`
mysql -h127.0.0.1 -uroot -p123456 -e "
use mysql;
select Host,User,Password from user INTO OUTFILE '/tmp/select$1.xls';
use tempdb;
select count(*)  as cou from tb_tmp  union select count(*) as cou from tb_tmp1 INTO OUTFILE '/tmp/tatol$1.xls';
quit
"
echo "文件select为XXX，文件tatol为XXX">>/tmp/ReadMe.txt
sudo tar -cvf xxx$1.tar /tmp/select$1.xls /tmp/tatol$1.xls /tmp/ReadMe.txt
if [ $? -eq 0 ]
then
    sudo rm  /tmp/select$1.xls /tmp/tatol$1.xls /tmp/ReadMe.txt  
else
	echo "fuck"
fi
sz xxx$1.tar
rm -f xxx$1.tar
echo $date1